import 'package:safetymonitor/generated/json/base/json_convert_content.dart';
import 'package:safetymonitor/app/data/entities/auth/app_upgrade_entity.dart';

AppUpgradeEntity $AppUpgradeEntityFromJson(Map<String, dynamic> json) {
  final AppUpgradeEntity appUpgradeEntity = AppUpgradeEntity();
  final String? upgradeDescription = jsonConvert.convert<String>(json['upgradeDescription']);
  if (upgradeDescription != null) {
    appUpgradeEntity.upgradeDescription = upgradeDescription;
  }
  final int? isForceUpgrade = jsonConvert.convert<int>(json['isForceUpgrade']);
  if (isForceUpgrade != null) {
    appUpgradeEntity.isForceUpgrade = isForceUpgrade;
  }
  final int? clientType = jsonConvert.convert<int>(json['clientType']);
  if (clientType != null) {
    appUpgradeEntity.clientType = clientType;
  }
  final String? downloadAddress = jsonConvert.convert<String>(json['downloadAddress']);
  if (downloadAddress != null) {
    appUpgradeEntity.downloadAddress = downloadAddress;
  }
  final String? appVersion = jsonConvert.convert<String>(json['appVersion']);
  if (appVersion != null) {
    appUpgradeEntity.appVersion = appVersion;
  }
  final String? packageSize = jsonConvert.convert<String>(json['packageSize']);
  if (packageSize != null) {
    appUpgradeEntity.packageSize = packageSize;
  }
  final String? minCompatibleVersion = jsonConvert.convert<String>(json['minCompatibleVersion']);
  if (minCompatibleVersion != null) {
    appUpgradeEntity.minCompatibleVersion = minCompatibleVersion;
  }
  final String? apkAddress = jsonConvert.convert<String>(json['apkAddress']);
  if (apkAddress != null) {
    appUpgradeEntity.apkAddress = apkAddress;
  }
  return appUpgradeEntity;
}

Map<String, dynamic> $AppUpgradeEntityToJson(AppUpgradeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['upgradeDescription'] = entity.upgradeDescription;
  data['isForceUpgrade'] = entity.isForceUpgrade;
  data['clientType'] = entity.clientType;
  data['downloadAddress'] = entity.downloadAddress;
  data['appVersion'] = entity.appVersion;
  data['packageSize'] = entity.packageSize;
  data['minCompatibleVersion'] = entity.minCompatibleVersion;
  data['apkAddress'] = entity.apkAddress;
  return data;
}

extension AppUpgradeEntityExtension on AppUpgradeEntity {
  AppUpgradeEntity copyWith({
    String? upgradeDescription,
    int? isForceUpgrade,
    int? clientType,
    String? downloadAddress,
    String? appVersion,
    String? packageSize,
    String? minCompatibleVersion,
    String? apkAddress,
  }) {
    return AppUpgradeEntity()
      ..upgradeDescription = upgradeDescription ?? this.upgradeDescription
      ..isForceUpgrade = isForceUpgrade ?? this.isForceUpgrade
      ..clientType = clientType ?? this.clientType
      ..downloadAddress = downloadAddress ?? this.downloadAddress
      ..appVersion = appVersion ?? this.appVersion
      ..packageSize = packageSize ?? this.packageSize
      ..minCompatibleVersion = minCompatibleVersion ?? this.minCompatibleVersion
      ..apkAddress = apkAddress ?? this.apkAddress;
  }
}